package com.aat.dxfy.kafka;

import java.net.URI;

import org.java_websocket.WebSocket.READYSTATE;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;

public class WebSocketTest {
	public static WebSocketClient client;

	public static void main(String[] args) throws Exception {
		client = new WebSocketClient(new URI("ws://140.143.49.194:8082/api/notifications"), new Draft_6455()) {

			@Override
			public void onClose(int arg0, String arg1, boolean arg2) {
				System.out.println("onClose:" + arg0 + "," + arg1 + "," + arg2);
			}

			@Override
			public void onError(Exception arg0) {
				System.out.println("onError:" + arg0.getMessage());
			}

			@Override
			public void onMessage(String arg0) {
				System.out.println("onMessage:" + arg0);
			}

			@Override
			public void onOpen(ServerHandshake arg0) {
				System.out.println("onOpen:" + arg0.getHttpStatusMessage());
			}

		};

		client.connect();

		while (!client.getReadyState().equals(READYSTATE.OPEN)) {
			System.out.println("还没有打开");
		}
		System.out.println("打开了");
	}


}
